package com.skt.common_hr.myprofile.events
{
	import mx.validators.ValidationResult;
	import mx.validators.Validator;
	
	public class KorMPhoneNumberValidator extends Validator
	{
		//반환값
		private var results:Array;
		
		//생성자
		public function KorMPhoneNumberValidator()
		{
			super();
		}
		
		override protected function doValidation(value:Object):Array
		{
			results = [];
			
			var valStr:String = String(value);
			
			results = super.doValidation(value);
			
			//에러발상시
			if(results.length > 0)
			{
				return results;
			}
			
			//문자체크
			var chkInvaildChar:RegExp = /[^0-9\-]+/g;
			if(chkInvaildChar.test(valStr))
			{
				results.push(new ValidationResult(true, null, "NaN","번호에 유효하지 않은 문자가 있습니다."));
				return results;
			}
			
			var chkPhoneNum:RegExp = /(0(1([013456789]))-)(-?)(\d{3,4}-)(\d{4})/g;
			
			if(!chkPhoneNum.test(valStr))
			{
				results.push(new ValidationResult(true, null, "NaN", "유형에 맞게 입력하세요. Ex) 010-1234-1234  "));
				return results;
			}
			return results;
		}
	}
}